Source for file RenameFolder.php

Documentation is available at RenameFolder.php

  1. <?php /*
  2.  * FCKeditor - The text editor for internet
  3.  * Copyright (C) 2003-2005 Frederico Caldeira Knabben
  4.  * 
  5.  * Licensed under the terms of the GNU Lesser General Public License:
  6.  *         http://www.opensource.org/licenses/lgpl-license.php
  7.  * 
  8.  * For further information visit:
  9.  *         http://www.fckeditor.net/
  10.  * 
  11.  * File Name: RenameFolder.php
  12.  *     Implements the DeleteFile command to delete a file
  13.  *     in the current directory. Output is in XML
  14.  * 
  15.  * File Authors:
  16.  *         Grant French (grant@mcpuk.net)
  17.  */
  18. class RenameFolder {
  19.     var $fckphp_config;
  20.     var $type;
  21.     var $cwd;
  22.     var $actual_cwd;
  23.     var $newfolder;
  24.     
  25.     function RenameFolder($fckphp_config,$type,$cwd{
  26.         $this->fckphp_config=$fckphp_config;
  27.         $this->type=$type;
  28.         $this->raw_cwd=$cwd;
  29.         $this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
  30.         $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
  31.         $this->foldername=str_replace(array("..","/"),"",$_GET['FolderName']);
  32.         $this->newname=str_replace(array("..","/"),"",$this->checkName($_GET['NewName']));
  33.     }
  34.     
  35.     function checkName($name{
  36.         $newName="";
  37.         for ($i=0;$i<strlen($name);$i++{
  38.             if (in_array($name[$i],$this->fckphp_config['DirNameAllowedChars'])) $newName.=$name[$i];
  39.         }
  40.         return $newName;
  41.     }
  42.     
  43.     function run({
  44.         $result1=false;
  45.  
  46.         
  47.         if ($this->newname!=''{
  48.             $result1=rename($this->real_cwd.'/'.$this->foldername,$this->real_cwd.'/'.$this->newname);
  49.         }
  50.         
  51.         header ("content-type: text/xml");
  52.         echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
  53.         ?>
  54. <Connector command="RenameFolder" resourceType="<?php echo $this->type?>">
  55.     <CurrentFolder path="<?php echo $this->raw_cwd?>" url="<?php echo $this->actual_cwd?>" />
  56.     <?php
  57.         if ($result1{
  58.             $err_no=0;
  59.         else {
  60.             $err_no=602;
  61.         }
  62.         
  63.     ?>
  64.     <Error number="<?php echo "".$err_no?>" />
  65. </Connector>
  66.         <?php
  67.     }
  68. }
  69.  
  70. ?>

Documentation generated on Mon, 05 May 2008 16:22:38 +0400 by phpDocumentor 1.4.0